package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.StudentBean;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StudentServiceImpl implements IStudentService {

    @Autowired
    private IStudentMapper studentMapper;

    @Override
    public IPage<StudentBean> findByItem(Integer pageNO, String name, String className, String roomAddress) {



        return studentMapper.findByItem(new Page(pageNO, 3), name, className, roomAddress);
    }

    @Override
    public void del(int id) {
        studentMapper.deleteById(id);
    }

    @Override
    public void add(StudentBean student) {
        studentMapper.insert(student);
    }

    @Override
    public void update(int studentId, int roomId) {
        StudentBean student = studentMapper.selectById(studentId);
        student.setRoomId(roomId);
        studentMapper.updateById(student);
    }

    @Override
    public StudentBean findById(int id) {
        return studentMapper.findById(id);
    }
}
